# -*- encoding=utf8 -*-
__author__ = "yupf"

from airtest.core.api import *
from poco.drivers.ios import iosPoco


def select_date(poco: iosPoco, yyyy: str, mm: str, dd: str):
    """
    @params:d 日期，格式yyyy-mm-dd
    
    """

    months = {
        "01": "January",
        "02": "February",
        "03": "March",
        "04": "April",
        "05": "May",
        "06": "June",
        "07": "July",
        "08": "August",
        "09": "September",
        "10": "October",
        "11": "November",
        "12": "December"
    }

    act_date = f'{months[mm]} {dd[1] if dd[0] == "0" else dd}, {yyyy}'
    #     act_date = f'June 9, 2023, from €82 '
    poco("Departure date").click()

    wait(Template(r"tpl1685374196463.png", record_pos=(0.001, -0.796), resolution=(1242, 2208)))

    log(act_date)
    #     poco(act_date,type="Button").wait_for_appearance()
    #     poco(act_date,type="Button").click()

    with poco.freeze() as fz:
        #         fz(nameMatches=f'^{act_date}, from .+$',type="Button").click()
        fz('June 9, 2023, from €82').click()

    wait(Template(r"tpl1685374526345.png", record_pos=(0.338, 0.809), resolution=(1242, 2208)))

    touch(Template(r"tpl1685374112343.png", record_pos=(0.338, 0.804), resolution=(1242, 2208)))
